/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lab5_Test.Test4;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author THIEN
 */
public class ThreadTwo extends MyThread {

    public ThreadTwo(Data d) {
        super(d);
    }

    @Override
    public void run() {
        this.displayArr();

    }
    /*
     * display array
     */

    public void displayArr() {

        for (int i = 0; i < 5; i++) {
            synchronized (this.d) {
                if (d.flag) {
                    System.out.println(d.temp);
                    d.flag = false;
                }
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                //Logger.getLogger(ThreadTwo.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}
